<%@ page contentType="text/html;charset=utf-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/messages.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>


<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>修 改</title>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/public.js"></script>


<link href="styles/aux_window.css" rel="stylesheet" type="text/css">

    <link rel="stylesheet" type="text/css" media="all" href="${ctx}/scripts/jscalendar-1.0/calendar-blue2.css" title="win2k-cold-1" />
    <!-- main calendar program -->
    <script type="text/javascript" src="${ctx}/scripts/jscalendar-1.0/calendar.js"></script>
    <!-- language for the calendar
    <script type="text/javascript" src="jscalendar-1.0/lang/cn_utf8.js"></script>
    -->
     <script type="text/javascript" src="${ctx}/scripts/jscalendar-1.0/lang/cn_utf8.js"></script>
    <!-- the following script defines the Calendar.setup helper function, which makes
       adding a calendar a matter of 1 or 2 lines of code. -->
    <script type="text/javascript" src="${ctx}/scripts/jscalendar-1.0/calendar-setup.js"></script>

<script language="JavaScript" type="text/javascript">
function sm(){
   	var  inputDate=document.getElementById("startTimeDate").value;
   	var  oldDate=document.getElementById("oldStartTime").value;
    // alert(" oldDate=" +oldDate);
    document.secScheduleForm.submit();

	var year1 = inputDate.substring(0,4);
	var month1 = inputDate.substring(5,7);
	var date1 = inputDate.substring(8,10);

    if(date1.substring(0,1)==0){
     date1=date1.substring(1);
     }
    // alert(" oldDate2="+window.opener.oldDate);
     window.opener.changeMonthStyle(year1,month1,date1);
     window.opener.onDateClick(year1,month1,date1);
}

function show3(selects){
 var values = selects.options[selects.selectedIndex].value;
if (values=="31")
{
layer1.style.display="none";
}
else{
layer1.style.display="";
}
}


function modifyDateValidate(){
   	var content = document.secScheduleForm.content.value;
	var title = document.secScheduleForm.title.value;

	var  inputDate=document.getElementById("startTimeDate").value;
    var  endUpDate = document.secScheduleForm.endUpDate.value;
    //alert(" endUpDate"+endUpDate);

    if(title==null||title==""){
    alert("标题不能为空,请输入！");
    return false;
    }

    if(content==null||content==""){
    alert("详细内容不能为空,请输入！");
    return false;
    }

   if((endUpDate!=null)&&(endUpDate!="")&&(inputDate>endUpDate)){
    alert("起至日期不能大于截至日期,请重新输入！");
    return false;
    }

    return true;
}

function modifyType(){
if(!modifyDateValidate()) return;
if(values==31){
window.showModalDialog('${ctx}/pages/webframework/sec/Aux_warning1_edit.jsp',
 window,'dialogWidth:330px;dialogHeight:185px;help:no;status:no;scroll:no;center');
}else{
 window.showModalDialog('${ctx}/pages/webframework/sec/Aux_warning1_1_edit.jsp',
 window,'dialogWidth:450px;dialogHeight:185px;help:no;status:no;scroll:no;center');
}
}


function editJudgeType(edit){
document.getElementById("modifyTypeId").value=edit;
sm();
}


function showCalendar(id, format, showsTime, showsOtherMonths) {
  var el = document.getElementById(id);
  if (_dynarch_popupCalendar != null) {
    // we already have some calendar created
    _dynarch_popupCalendar.hide();                 // so we hide it first.
  } else {
    // first-time call, create the calendar.
    var cal = new Calendar(1, null, selected, closeHandler);
    // uncomment the following line to hide the week numbers
    // cal.weekNumbers = false;
    if (typeof showsTime == "string") {
      cal.showsTime = true;
      cal.time24 = (showsTime == "24");
    }
    if (showsOtherMonths) {
      cal.showsOtherMonths = true;
    }
    _dynarch_popupCalendar = cal;                  // remember it in the global var
    cal.setRange(1900, 2070);        // min/max year allowed.
    cal.create();
  }
  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use

  // the reference element that we pass to showAtElement is the button that
  // triggers the calendar.  In this example we align the calendar bottom-right
  // to the button.
  _dynarch_popupCalendar.showAtElement(el.nextSibling, "Br");        // show the calendar

  return false;
}


function selected(cal, date) {
  cal.sel.value = date; // just update the date in the input field.
  if (cal.dateClicked && (cal.sel.id == "endUpDate"))
    // if we add this call we close the calendar on single-click.
    // just to exemplify both cases, we are using this only for the 1st
    // and the 3rd field, while 2nd and 4th will still require double-click.
    cal.callCloseHandler();
}

function closeHandler(cal) {
  cal.hide();                        // hide the calendar
//  cal.destroy();
  _dynarch_popupCalendar = null;
}

// This function shows the calendar under the element having the given id.
// It takes care of catching "mousedown" signals on document and hiding the
// calendar if the click was outside.
function showCalendar(id, format, showsTime, showsOtherMonths) {
  var el = document.getElementById(id);
  if (_dynarch_popupCalendar != null) {
    // we already have some calendar created
    _dynarch_popupCalendar.hide();                 // so we hide it first.
  } else {
    // first-time call, create the calendar.
    var cal = new Calendar(1, null, selected, closeHandler);
    // uncomment the following line to hide the week numbers
    // cal.weekNumbers = false;
    if (typeof showsTime == "string") {
      cal.showsTime = true;
      cal.time24 = (showsTime == "24");
    }
    if (showsOtherMonths) {
      cal.showsOtherMonths = true;
    }
    _dynarch_popupCalendar = cal;                  // remember it in the global var
    cal.setRange(1900, 2070);        // min/max year allowed.
    cal.create();
  }
  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use

  // the reference element that we pass to showAtElement is the button that
  // triggers the calendar.  In this example we align the calendar bottom-right
  // to the button.
  _dynarch_popupCalendar.showAtElement(el.nextSibling, "Br");        // show the calendar

  return false;
}

var MINUTE = 60 * 1000;
var HOUR = 60 * MINUTE;
var DAY = 24 * HOUR;
var WEEK = 7 * DAY;

</script>

<script>
function init(){
    //编辑日程后
    var newId ="${newScheduleId}";
    var oldId="${oldScheduleId}";
    var hasUpValue="${hasUpdateValue}";
    var upTypeValue="${updateType}";

    var condition1=(oldId!=undefined)&&(oldId!=null)&&(oldId!="");
    var upTypeCondition=(upTypeValue!=undefined)&&(upTypeValue=="all");
    var condition2=(newId!=undefined)&&(newId!="")&&(hasUpValue!=undefined)&&(hasUpValue=="correct");

    //alert(" cond1"+condition1+" cond2"+condition2+" "+upTypeCondition);

     //all时删除原来提醒,如果有符合有数据条件增加一条记录
    if(condition1&&upTypeCondition){
	window.opener.parent.del(oldId);
	if(condition2){
	window.opener.parent.mySend_request("${ctx}/secScheduleAction.do?method=getSecScheduleXmlById&scheduleId="+newId+"&time" + new Date().getTime(),3);
	}
	window.close();
	}
	//thisOneOnly 判断有没有数据,有就send_request否则不做
    if((upTypeValue!=undefined)&&(upTypeValue=="thisOneOnly")&&condition2){
	window.opener.parent.mySend_request("${ctx}/secScheduleAction.do?method=getSecScheduleXmlById&scheduleId="+newId+"&time" + new Date().getTime(),3);
	window.close();
	}
	//thisOneOnlye 但是没有提醒
	if((upTypeValue!=undefined)&&(upTypeValue=="thisOneOnly")&&!((hasUpValue!=undefined)&&(hasUpValue=="correct")) ){
	window.close();
	}
}
window.onload=function(){init();}
</script>


</head>

<body>
<form name="secScheduleForm" id="secScheduleForm" method="post" action="${ctx}/secScheduleAction.do?method=updateSecSchedule">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="window_head"><img src="${ctx}/images/window_head_arrow.gif"/>修改活动信息</td>
  </tr>
    <input type="hidden" name="scheduleId" value="${secScheduleDO.scheduleId}"/>
    <input type="hidden" id="modifyTypeId" name="modifyTypeName" value=""/>
  <tr>
    <td class="content"><table border="0" cellpadding="5" cellspacing="0">
        <tr>
          <td>标 题：</td>
          <td colspan="3" class="require"><table border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td><input name="title" type="text" class="inputtext" value="${secScheduleDO.title}" size="40" /></td>
              <td class="between_space_both"><img src="${ctx}/images/ico_lookup.gif" alt="请点选已设标题"/></td>
              <td>最多20字</td>
            </tr>
          </table></td>
        </tr>
        <tr>
          <td>时 间：</td>
          <td colspan="3" class="require"><table border="0" cellspacing="0" cellpadding="0">
            <tr>
            <input type="hidden" id="oldStartTime" value="${secScheduleDO.startTime}"/>
              <td><input name="startTimeDate" type="text" class="inputtext" value="${secScheduleDO.startTimeDate}" size="10" /></td>
              <td>&nbsp;</td>
              <td><input name="startTimeHour" type="text" class="inputtext" value="${secScheduleDO.startTimeHour}" size="5" /></td>
            </tr>
          </table></td>
        </tr>
        <tr>
          <td valign="top">详细内容：</td>
          <td colspan="3"><textarea name="content" cols="43" rows="4">${secScheduleDO.content}</textarea></td>
        </tr>
        <tr>
          <td>重复周期：</td>
          <td>
              <html:select  property="repeatCycle" value="${secScheduleDO.repeatCycle}"  onchange="show3(this)">
                <html:options collection="repeatCycleList"  property="dictId" labelProperty="dictName"/>
               </html:select>
          </td>

             <td colspan="2">
            <div id="layer1" style="display: none;">
                <table border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="66" class="">截至日期：</td>
                    <td><input type="text" name="endUpDate" id="endUpDate" size="10" value="${secScheduleDO.endTimeDate}"
				><input type="reset" value=" ... "
				onclick="return showCalendar('endUpDate', '%Y-%m-%d', '24', true);"></td>
                  <td></td>
                  </tr>
                </table>
             </div>
              </td>


        </tr>
        <tr>
          <td>提 醒：</td>

       <td>
      <html:select  property="remindCycle" value="${secScheduleDO.remindCycle}">
      <html:options collection="reminderCycleList"  property="dictId" labelProperty="dictName"/>
      </html:select>
       </td>

        </tr>
      </table></td>
  </tr>
  <tr>
    <td class="window_footer"><table border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_11"></td>
              <td class="buttonOffMiddle" id="btn1_12" onClick="modifyType();"
          >
              <img src="${ctx}/images/ico_ok.gif"  border="0" align="absbottom"> 保
                存</td>
              <td class="buttonOffRight" id="btn1_13"></td>
            </tr>
        </table></td>
        <td class="btn_between_space"></td>
        <td><table border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td class="buttonOffLeft" id="btn1_21"></td>
              <td class="buttonOffMiddle" id="btn1_22" onClick="closewin();"
              ><img src="${ctx}/images/ico_cancel.gif" border="0" align="absbottom"> 取
                消</td>
              <td class="buttonOffRight" id="btn1_23"></td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>
</form>
</body>
<script language="javascript">
var values = "${secScheduleDO.repeatCycle}";
if (values=="31")
{
layer1.style.display="none";
}
else{
layer1.style.display="";
}
</script>
</html>